package stage1.module3.homework5;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class Homework5 {
    public static void main(String[] args) {
        //所有种类的扑克牌
        String[] cards = {"3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K", "A", "2", "small_joker", "big_joker"};
        //创建一副扑克牌
        ArrayList<Card> allCards = new ArrayList<>();
        for(int i = 0; i < cards.length; i++){
            Card card = new Card(cards[i], i);
            if("small_joker".equals(card.getName()) || "big_joker".equals(card.getName())){
                allCards.add(card);
            }else{
                for(int j = 0; j < 4; j++){
                    allCards.add(card);
                }
            }
        }
        //洗牌
        Collections.shuffle(allCards);
        //发牌
        List<Card> one = allCards.subList(0, 17);
        List<Card> two = allCards.subList(17, 34);
        List<Card> three = allCards.subList(34, 51);
        //对玩家手中的牌进行排序
        Collections.sort(one);
        Collections.sort(two);
        Collections.sort(three);

        //查看玩家手牌和底牌
        System.out.println("第一个玩家手牌：" + one);
        System.out.println("第二个玩家手牌：" + two);
        System.out.println("第三个玩家手牌：" + three);
        System.out.println("底牌：[" + allCards.get(51) + "," + allCards.get(52) + "," + allCards.get(53) + "]");
    }
}
